cmake_minimum_required(VERSION 3.0.2)
project(sdplt)


# include(src/SDPltDDSPose/SDPltDDSPose.cmake)
#config dds

find_package(catkin REQUIRED COMPONENTS
  message_generation
  roscpp
  rospy
  std_msgs
  geometry_msgs
  mavros
)

find_package(PCL 1.7 REQUIRED)
find_package(octomap REQUIRED)

## Generate messages in the 'msg' folder
#add_message_files(
#  FILES
#)

generate_messages(
  DEPENDENCIES
  std_msgs
  geometry_msgs
)

catkin_package(
  INCLUDE_DIRS 
  LIBRARIES
  CATKIN_DEPENDS)

if(NOT fastcdr_FOUND)
    find_package(fastcdr REQUIRED)
endif()

if(NOT foonathan_memory_FOUND)
    find_package(foonathan_memory REQUIRED)
endif()

if(NOT fastrtps_FOUND)
    find_package(fastrtps REQUIRED)
endif()

#Check C++11
include(CheckCXXCompilerFlag)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
        CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    check_cxx_compiler_flag(-std=c++11 SUPPORTS_CXX11)
    if(NOT SUPPORTS_CXX11)
        message(FATAL_ERROR "Compiler doesn't support C++11")
    endif()
endif()



include_directories( ${catkin_INCLUDE_DIRS} ${PCL_INCLUDE_DIRS})

link_directories(${PCL_LIBRARY_DIRS})

#src
file(GLOB SDPLT_DDS_SRC "src/SDPltDDS/*")
file(GLOB SDPLT_DDS_POSE_SRC "src/SDPltDDSPose/*")
file(GLOB SDPLT_DDS_PUB_SRC "src/pub/*")
file(GLOB SDPLT_DDS_SUB_SRC "src/sub/*")
file(GLOB SDPLT_UTILS_SRC "/src/SDPltDDSUtils/*.hpp")
add_executable(SDPltDDSPosepub ${SDPLT_UTILS_SRC} ${SDPLT_DDS_SRC} ${SDPLT_DDS_POSE_SRC} ${SDPLT_DDS_PUB_SRC})
add_executable(SDPltDDSPosesub ${SDPLT_UTILS_SRC} ${SDPLT_DDS_SRC} ${SDPLT_DDS_POSE_SRC} ${SDPLT_DDS_SUB_SRC})

##link libs
SET(SDPLT_DDS_LIBS fastrtps fastcdr foonathan_memory)
target_link_libraries(SDPltDDSPosepub
  ${catkin_LIBRARIES}
  ${SDPLT_DDS_LIBS}
  rt
  unionsys_core
  ${PCL_LIBRARIES} 
  ${OCTOMAP_LIBRARIES}
)
target_link_libraries(SDPltDDSPosesub
  ${catkin_LIBRARIES}
  ${SDPLT_DDS_LIBS}
  rt
  unionsys_core
  ${PCL_LIBRARIES} 
  ${OCTOMAP_LIBRARIES}
)